import React, { Component } from 'react'

export default class App extends Component {
  state = {
    type:'miaohao'
  }

  //新生命周期，相当于将componentwillmount和componentwillreceiveprops合并，static不要忘记
  static getDerivedStateFromProps(nextProps,nextState){
    return{
        type: nextState.type.substring(0, 1).toUpperCase() + nextState.type.substring(1)
    }
  }
  render() {
    return (
      <div>
          <button onClick={()=>{
              this.setState({
                  type:'xiaoman'
              })
          }}>click</button>
          {this.state.type}
      </div>
    )
  }
}
